import DBConnection from "../../service/unit/mysql";

export async function deleteArticle(conn:DBConnection, TABLE_NAME:string, CONDITION) {
    const {storeId} = CONDITION;
    const queryResult = await conn.Query.query(TABLE_NAME);
    await updateArticle(conn, TABLE_NAME, queryResult, storeId);
    return 'ok'
}


function updateArticle(conn, TABLE_NAME, queryResult, storeId) {
    const {title} = queryResult;
    const length = queryResult.length;
    const _title = conn.strEncode(`${title}${length}`);
    const _knex = conn.knex;
    return _knex(TABLE_NAME).where('id','=',storeId).update({is_active:0,title:_title});
}